/*
 * Key.c
 *
 *  Created on: 2024��9��4��
 *      Author: zizhong
 */

#include "Key.h"
#include "foc_declare.h"

static uint32_t KEY_Cnt = 0;
extern MOTOR_Vars_t motorVars;

__interrupt void INT_KEY1_XINT_ISR(void)
{
    if(motorVars.ctrlStateUse == CTRL_STOP)
    {
        motorVars.ctrlStateUse = CTRL_RUN;
        GPIO_writePin(EN_GATE, 1);
    }

    else if(motorVars.ctrlStateUse == CTRL_RUN)
    {
        motorVars.ctrlStateUse = CTRL_STOP;
        GPIO_writePin(EN_GATE, 0);
    }


    KEY_Cnt++;
    Interrupt_clearACKGroup(INT_KEY1_XINT_INTERRUPT_ACK_GROUP);
}
__interrupt void INT_KEY2_XINT_ISR(void)
{


    KEY_Cnt++;
    Interrupt_clearACKGroup(INT_KEY2_XINT_INTERRUPT_ACK_GROUP);
}
__interrupt void INT_KEY3_XINT_ISR(void)
{

    KEY_Cnt++;
    Interrupt_clearACKGroup(INT_KEY3_XINT_INTERRUPT_ACK_GROUP);
}
__interrupt void INT_KEY4_XINT_ISR(void)
{

    KEY_Cnt++;
    Interrupt_clearACKGroup(INT_KEY4_XINT_INTERRUPT_ACK_GROUP);
}
